<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<spring:message code="user.workspace.label.tab.cursos" var="LABEL_TAB_CURSOS"/>
<spring:message code="user.workspace.label.tab.mundo3D" var="LABEL_TAB_MUNDO_3D" />

<script>
// Menu 
if("${menuActivo}" == $("#mnuHome").attr("id")){
	$("#mnuHome").attr("class","active");
	$("#mnuNosotros").attr("class","");
	$("#mnuServicios").attr("class","");
	$("#mnuCursos").attr("class","");
	$("#mnuForo").attr("class","");
	$("#mnuRegistrate").attr("class","");
	$("#mnuContactanos").attr("class","");
	$("#mnuMisCuros").attr("class","mnuAuntenticated");
	$("#mnuMundo3D").attr("class","mnuAuntenticated");
	$("#mnuClassOnline").attr("class","mnuAuntenticated");
}
if("${menuActivo}" == $("#mnuNosotros").attr("id")){
    $("#mnuHome").attr("class","");
    $("#mnuNosotros").attr("class","active");
    $("#mnuServicios").attr("class","");
    $("#mnuCursos").attr("class","");
    $("#mnuForo").attr("class","");
    $("#mnuRegistrate").attr("class","");
    $("#mnuContactanos").attr("class","");
	$("#mnuMisCuros").attr("class","mnuAuntenticated");
	$("#mnuMundo3D").attr("class","mnuAuntenticated");
	$("#mnuClassOnline").attr("class","mnuAuntenticated");
}
if("${menuActivo}" == $("#mnuServicios").attr("id")){
    $("#mnuHome").attr("class","");
    $("#mnuNosotros").attr("class","");
    $("#mnuServicios").attr("class","active");
    $("#mnuCursos").attr("class","");
    $("#mnuForo").attr("class","");
    $("#mnuRegistrate").attr("class","");
    $("#mnuContactanos").attr("class","");
	$("#mnuMisCuros").attr("class","mnuAuntenticated");
	$("#mnuMundo3D").attr("class","mnuAuntenticated");
	$("#mnuClassOnline").attr("class","mnuAuntenticated");
}
if("${menuActivo}" == $("#mnuCursos").attr("id")){
    $("#mnuHome").attr("class","");
    $("#mnuNosotros").attr("class","");
    $("#mnuServicios").attr("class","");
    $("#mnuCursos").attr("class","active");
    $("#mnuForo").attr("class","");
    $("#mnuRegistrate").attr("class","");
    $("#mnuContactanos").attr("class","");
	$("#mnuMisCuros").attr("class","mnuAuntenticated");
	$("#mnuMundo3D").attr("class","mnuAuntenticated");
	$("#mnuClassOnline").attr("class","mnuAuntenticated");
}
if("${menuActivo}" == $("#mnuForo").attr("id")){
    $("#mnuHome").attr("class","");
    $("#mnuNosotros").attr("class","");
    $("#mnuServicios").attr("class","");
    $("#mnuCursos").attr("class","");
    $("#mnuForo").attr("class","active");
    $("#mnuRegistrate").attr("class","");
    $("#mnuContactanos").attr("class","");
	$("#mnuMisCuros").attr("class","mnuAuntenticated");
	$("#mnuMundo3D").attr("class","mnuAuntenticated");
	$("#mnuClassOnline").attr("class","mnuAuntenticated");
}
if("${menuActivo}" == $("#mnuRegistrate").attr("id")){
    $("#mnuHome").attr("class","");
    $("#mnuNosotros").attr("class","");
    $("#mnuServicios").attr("class","");
    $("#mnuCursos").attr("class","");
    $("#mnuForo").attr("class","");
    $("#mnuRegistrate").attr("class","active");
    $("#mnuContactanos").attr("class","");
	$("#mnuMisCuros").attr("class","mnuAuntenticated");
	$("#mnuMundo3D").attr("class","mnuAuntenticated");
	$("#mnuClassOnline").attr("class","mnuAuntenticated");
}
if("${menuActivo}" == $("#mnuContactanos").attr("id")){
    $("#mnuHome").attr("class","");
    $("#mnuNosotros").attr("class","");
    $("#mnuServicios").attr("class","");
    $("#mnuCursos").attr("class","");
    $("#mnuForo").attr("class","");
    $("#mnuRegistrate").attr("class","");
    $("#mnuContactanos").attr("class","active");
	$("#mnuMisCuros").attr("class","mnuAuntenticated");
	$("#mnuMundo3D").attr("class","mnuAuntenticated");
	$("#mnuClassOnline").attr("class","mnuAuntenticated");
}
if("${menuActivo}" == $("#mnuMisCursos").attr("id")){
    $("#mnuHome").attr("class","");
    $("#mnuNosotros").attr("class","");
    $("#mnuServicios").attr("class","");
    $("#mnuCursos").attr("class","");
    $("#mnuForo").attr("class","");
    $("#mnuRegistrate").attr("class","");
    $("#mnuContactanos").attr("class","");
    $("#mnuMisCursos").attr("class","active mnuAuntenticated");
    $("#mnuMundo3D").attr("class","mnuAuntenticated");
    $("#mnuClassOnline").attr("class","mnuAuntenticated");
}
if("${menuActivo}" == $("#mnuMundo3D").attr("id")){
    $("#mnuHome").attr("class","");
    $("#mnuNosotros").attr("class","");
    $("#mnuServicios").attr("class","");
    $("#mnuCursos").attr("class","");
    $("#mnuForo").attr("class","");
    $("#mnuRegistrate").attr("class","");
    $("#mnuContactanos").attr("class","");
    $("#mnuMisCursos").attr("class","mnuAuntenticated");
    $("#mnuMundo3D").attr("class","active mnuAuntenticated");
    $("#mnuClassOnline").attr("class","mnuAuntenticated");
}
if("${menuActivo}" == $("#mnuClassOnline").attr("id")){
    $("#mnuHome").attr("class","");
    $("#mnuNosotros").attr("class","");
    $("#mnuServicios").attr("class","");
    $("#mnuCursos").attr("class","");
    $("#mnuForo").attr("class","");
    $("#mnuRegistrate").attr("class","");
    $("#mnuContactanos").attr("class","");
    $("#mnuMisCursos").attr("class","mnuAuntenticated");
    $("#mnuMundo3D").attr("class","mnuAuntenticated");
    $("#mnuClassOnline").attr("class","active mnuAuntenticated");
}

$(document).ready(function(){
	$("#resgisterForm").validate({
        onkeyup: false,
        onfocusout: false,
        rules: {
            "nombre" : {
                required : true
            },
            "apellido" : {
                required : true
            },
            "email": {
                required : true,
                email: true
            },
            "usuario": {
                required : true,
                minlength: 5
            },
            "password": {
                required : true
            },
            "password_confirm": {
                required : true,
                equalTo: "#password"
            }
        },
        messages: {
            "nombre": {
                required: '<spring:message code="register.form.validation.required.name" />',
            },
            "apellido": {
                required: '<spring:message code="register.form.validation.required.lastName" />',
            },
            "email": {
                required: '<spring:message code="register.form.validation.required.email" />',
                email: '<spring:message code="register.form.validation.valid.email" />'
            },
            "usuario": {
                required: '<spring:message code="register.form.validation.required.userName" />',
                minlength: '<spring:message code="register.form.validation.valid.userName" />'
            } ,
            "password": {
                required: '<spring:message code="register.form.validation.required.password" />',
                rangelength: '<spring:message code="register.form.validation.valid.password" />'
            },
            "password_confirm": {
                required: '<spring:message code="register.form.validation.required.confirmPassword" />',
                equalTo: '<spring:message code="register.form.validation.valid.confirmPassword" />'
            } 
        }
        
	});
	
    $.validator.addMethod("customFunction", function(value) {
        return value == "input";
    }, 'Please enter "input"!');
    
    $("#tabLeftcurso1").click();
    
    $("#formularioContacto").validate({
        onkeyup: false,
        onfocusout: false,
        rules: {
            "nombreContacto" : {
                required : true
            },
            "apellidoContacto" : {
                required : true
            },
            "emailContacto": {
                required : true,
                email: true
            },
            "messageContacto": {
            	required : true
            }
        },
        messages: {
            "nombreContacto": {
                required: '<spring:message code="register.form.validation.required.name" />',
            },
            "apellidoContacto": {
                required: '<spring:message code="register.form.validation.required.lastName" />',
            },
            "emailContacto": {
                required: '<spring:message code="register.form.validation.required.email" />',
                email: '<spring:message code="register.form.validation.valid.email" />'
            },
            "messageContacto": {
            	required: '<spring:message code="register.form.validation.required.message" />',
            }
        }
    });
    
    $("#formularioContacto").removeAttr("novalidate");
});

$("#submitRegister").click(function(){
	if($("#resgisterForm").validate()){
		$("#resgisterForm").submit();
	}
});

$("#btnSubmitContactForm").click(function(){
	if($("#formularioContacto").validate()){
		$("#formularioContacto").submit();
	}
});


$("#btnAdicionarTemas").click(function(){
	var cantTemas = $("#cantidadTemas").val();
	var text = "";
	
	for(i = 1; i <= cantTemas; i++){
		text += "<input type='text' name='temas' id='tema"+i+"' class='input-block-level' placeholder='Tema "+i+"'> <textarea name='temasDesc' id='temasDesc"+i+"' class='input-block-level' placeholder='Descripcion tema "+i+"'></textarea>";
	}
	
	$("#temasCursos").html(text);
});

$("#btnAdicionarMaterial").click(function(){
	var cantMaterial = $("#cantidadMaterial").val();
	var text = "";
	for(i = 1; i <= cantMaterial; i++){
		text += "<input type='text' name='materiales' id='material"+i+"' class='input-block-level' placeholder='Nombre Material "+i+"'> "+
				"<textarea name='materialesDesc' id='materialDesc"+i+"' class='input-block-level' placeholder='Descripcion Material "+i+"'></textarea>"+
				"<input type='file' id='materialFile"+i+"' name='materialFile' class='input-block-level' placeholder='Nombre del Material'>";
	}
	$("#materialCursos").html(text);
});

$("#btnAdicionarVideos").click(function(){
	var cantidadVideos = $("#cantidadVideos").val();
	var text = "";
	for(i = 1; i <= cantidadVideos; i++){
		text += "<input type='text' name='videos' id='video"+i+"' class='input-block-level' placeholder='Nombre Video "+i+"'> "+
				"<textarea name='videosDesc' id='videoDesc"+i+"' class='input-block-level' placeholder='Descripcion Video "+i+"'></textarea>"+
				"<input type='file' id='videoFile"+i+"' name='videoFile' class='input-block-level' placeholder='Nombre del Video'>";
	}
	$("#videosCurso").html(text);
});

function mostrarEditar(id){
	$("#"+id+"").css("display","block");
}

</script>